package cn.tedu.store.service;

import cn.tedu.store.entity.Order;
import cn.tedu.store.service.ex.*;
import feign.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 订单模块的业务层接口
 */
public interface IOrderService {

    /**
     * 基于用户id查询订单记录
     * @param uid
     * @return
     */
    List<Order> findByUid(Integer uid);

    /**
     * 基于用户id查询订单记录
     * @param uid
     * @return
     */
    List<Order> findByUidAndStatus(@Param("uid") Integer uid,@Param("status") Integer status);

    /**
     * 添加一条订单记录
     * 生成多条关联的订单项记录
     * @param aid
     * @param cids
     * @param uid
     * @param username
     */
    void createOrder(@Param("aid") Integer aid,Integer[] cids,@Param("uid") Integer uid,String username)
            throws RecordNotFoundException, ProductOutOfStockException, UpdateException,
            InsertException, DeleteException;

    /**
     * 基于订单id关闭订单支付窗口
     * @param oid
     * @param username
     */
    void closeOrder(Integer oid,String username)
        throws RecordNotFoundException, UpdateException;

    /**
     * 基于订单id修改订单状态
     * @param oid
     * @param status 0-未支付 1-已支付 2-已超时
     * @throws UpdateException
     */
    void changeStatus(@Param("oid") Integer oid,@Param("status")  Integer status)
        throws UpdateException;

}
